﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<link href="~/Content/js/bootstrap-fileinput/css/bootstrap.min.css" rel="stylesheet"><!--是多少--> 
<link href="~/Content/js/bootstrap-fileinput/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
<script src="~/Content/js/bootstrap-fileinput/js/jquery-2.0.3.min.js"></script>
<script src="~/Content/js/bootstrap-fileinput/js/fileinput.js" type="text/javascript"></script>
<script src="~/Content/js/bootstrap-fileinput/js/fileinput_locale_zh.js" type="text/javascript"></script>
<script src="~/Content/js/bootstrap-fileinput/js/bootstrap.min.js" type="text/javascript"></script>
<script>
    $(function () {
       
    })
   
</script>

<div class="easyui-layout" data-options="fit:true">
    <div class="page-header">
        <h1>Bootstrap File Input Example <small></h1>
        <h3 class="text-success">German Translation Demo</h3>
    </div>
    <form enctype="multipart/form-data">
        <span style="font-size:16px;">普通上传</span>
        <input id="file-0" class="file" type="file" multiple data-min-file-count="1">
        <br>
        <button type="submit" class="btn btn-primary">上传</button>
        <button type="reset" class="btn btn-default">重置</button>
    </form>
    <br>
    <form enctype="multipart/form-data">
        <div class="form-group">
            <span style="font-size:16px;">单个文件上传</span>
            <input id="file-0b" class="file" type="file">
        </div>
        <div class="form-group">
            <span style="font-size:16px;">多文件上传</span>
            <input id="file-1" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="2">
        </div>
        <div class="form-group">
            <span style="font-size:16px;">上传按钮只读，不可用</span>
            <input id="file-2" type="file" class="file" readonly data-show-upload="false">
        </div>
        <div class="form-group">
            <label>只显示上传按钮</label>
            <input id="file-3" type="file" multiple=true>
        </div>
        <div class="form-group">
            <label>以下是上传时附加上传其他数据</label>
            <input id="file-4" type="file" class="file" data-upload-url="#">
        </div>
       
        <div class="form-group">
            <label>自定义错误提示区域</label>
            <input type="file" class="file" id="test-upload" multiple>
            <div id="errorBlock" class="help-block"></div>
        </div>
        
        <div class="form-group">
            <label>以下是允许上传任何文件：data-preview-file-type="any"</label>
            <input id="file-5" class="file" type="file" multiple data-preview-file-type="any" data-upload-url="#" data-preview-file-icon="">
        </div>
    </form>
</div>

<script>
    $("#file-0").fileinput({
        uploadUrl: '/ExampleManage/Upload/UpdatePhoto',
        'allowedFileExtensions' : ['jpg', 'png','gif'],
    });
    $("#file-1").fileinput({
        uploadUrl: '/ExampleManage/Upload/UpdatePhoto', // you must set a valid URL here else you will get an error
        allowedFileExtensions : ['jpg', 'png','gif'],
        overwriteInitial: false,
        maxFileSize: 1000,
        maxFilesNum: 10,
        //allowedFileTypes: ['image', 'video', 'flash'],
        slugCallback: function(filename) {
            return filename.replace('(', '_').replace(']', '_');
        }
	});
    /*
    $(".file").on('fileselect', function(event, n, l) {
        alert('File Selected. Name: ' + l + ', Num: ' + n);
    });
    */
	$("#file-3").fileinput({
		showUpload: false,
		showCaption: false,
		browseClass: "btn btn-primary btn-lg",
		fileType: "any",
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
	});
	$("#file-4").fileinput({
		uploadExtraData: {kvId: '10'}
	});
    $(".btn-warning").on('click', function() {
        if ($('#file-4').attr('disabled')) {
            $('#file-4').fileinput('enable');
        } else {
            $('#file-4').fileinput('disable');
        }
    });
    $(".btn-info").on('click', function() {
        $('#file-4').fileinput('refresh', {previewClass:'bg-info'});
    });
   
    $(document).ready(function() {
        $("#test-upload").fileinput({
            'showPreview' : false,
            'allowedFileExtensions' : ['jpg', 'png','gif'],
            'elErrorContainer': '#errorBlock'
        });
       
    });
   
</script>
